﻿using ModelLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using BusinessLayer;

namespace WCF
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class ListService : IListService
    {
        private static IFUserB userObj = new UserB();
        private static IFShoppingListB shopObj = new ShoppingListB();
        //private static IFShoppingListProductB shopProdObj = new ShoppingListProductB();

        public int CreateUser(string fname, string lname, string uname, string email, string pass)
        {
             return userObj.CreateUser(fname, lname, uname, email, pass);
        }

        public void AddFriend(string userName, string friendName, string tokenId)
        {
            userObj.AddFriend(userName, friendName, tokenId);
        }

        public void CreateShoppingList(int userId, string listName, long completionDate)
        {
            shopObj.CreateShoppingList(userId, listName, completionDate);
        }

        public bool AddUserToShoppingList(int shoppingListId, string friendUserName, string uname, string tokenId)
        {
            return shopObj.AddUserToShoppingList(shoppingListId, friendUserName, uname, tokenId);
        }

        public void DeleteUserFromShoppingList(int shoppingListId, string friendUserName, string uname, string tokenId)
        {
            shopObj.DeleteUserFromShoppingList(shoppingListId, friendUserName, uname, tokenId);
        }


        public void AddProductToShoppingList(int shoppingListId, int productId, int amount)
        {
            shopObj.AddProductToShoppingList(shoppingListId, productId, amount);
        }


        public void DeleteProductFromShoppingList(int shoppingListId, int productId)
        {
            shopObj.DeleteProductFromShoppingList(shoppingListId, productId);
        }

        public List<User> SearchUsers(string searchString)
        {
            return userObj.SearchUsers(searchString);
        }


        public string Login(string username, string password)
        {
            
            return userObj.Login(username, password);;
        }

        public void MarkAsBought(int shoppingListId, int productId)
        {
            shopObj.MarkAsBought(shoppingListId, productId);
        }


        public void AddToBlackList(string userName, string blacklistUserName, string tokenId)
        {
            userObj.AddToBlacklist(userName, blacklistUserName, tokenId);
        }

        public void RemoveFromBlacklist(string userName, string blacklistUserName, string tokenId)
        {
            userObj.RemoveFromBlacklist(userName, blacklistUserName, tokenId);
        }


        public User GetUserByUname(string uname)
        {
            return userObj.SearchUName(uname);
        }


        public List<ShoppingList> GetShoppingListsWithUname(string uname)
        {
            return shopObj.GetShoppingListsWithUname(uname);
        }


        public List<Product> GetProductsWithListId(int listId)
        {
            return shopObj.GetProductsWithListId(listId);
        }

        public List<ModelLayer.User> GetFriends(string uname)
        {
            return userObj.GetFriends(uname);
        }


        public List<User> GetSharedUsersForShoppingList(string uname, int slist)
        {
            return shopObj.GetSharedUsersForShoppingList(uname, slist);
        }
    }
}
